﻿using UnityEngine;
using System.Collections;

public class ManualConnect : MonoBehaviour {

    public string serverIP = "192.168.1.65";
    public int port = 378;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {

        if (Input.GetKeyDown(KeyCode.Escape)) Application.Quit();

	}

    void OnGUI()
    {

        GUILayout.BeginHorizontal();

        GUILayout.Label("Server");
        serverIP = GUILayout.TextField(serverIP);

        if (GUILayout.Button("Connect"))
        {
            Network.Connect(serverIP, port);
        }

        GUILayout.EndHorizontal();

    }

    void OnConnectedToServer()
    {
        print("Connected to server at " + serverIP);

        // Don't need to load anything; that will happen for us.
    }

    void OnFailedToConnect(NetworkConnectionError error)
    {
        print(error);
    }
}
